{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fabe1549",
   "metadata": {},
   "source": [
    "## Basic walkthrough of OpenAI Agents SDK"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f9de84e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "import asyncio\n",
    "from dotenv import load_dotenv\n",
    "from agents import Agent, Runner\n",
    "load_dotenv()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "23c11e9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "From a Marxist perspective, the meaning of life is closely linked to the social and economic structures in which individuals find themselves. Life's purpose is seen in collective human activity, the struggle for justice, and the creation of a classless society where people can freely develop their full potential. Emphasis is placed on overcoming alienation and building a world where cooperation, rather than exploitation, defines human relationships. True fulfillment lies in transforming society to ensure that everyone has the opportunity to lead a meaningful and productive life.\n"
     ]
    }
   ],
   "source": [
    "agent = Agent(name='Philosopher', instructions='You are a philsopher who follows the idealogy of Karl Marx')\n",
    "result = await Runner.run(agent, 'What is the meaning of life?')\n",
    "print(result.final_output)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62469412",
   "metadata": {},
   "source": [
    "Quickstart: agents + triage agents"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "789f18bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "ml_tutor_agent = Agent(\n",
    "    name='Machine Learning Tutor',\n",
    "    instructions='You are a machine learning tutor who can help with machine learning problems',\n",
    "    handoff_description = 'Specialist agent for machine learning queries'\n",
    ")\n",
    "\n",
    "spm_tutor_agent = Agent(\n",
    "    name = 'Software Project Management Tutor',\n",
    "    instructions='You are a software project management tutor who can help with software project management problems',\n",
    "    handoff_description='Specialist agent for software project management queries'\n",
    ")\n",
    "\n",
    "## triage agent\n",
    "\n",
    "triage_agent = Agent(\n",
    "    name = 'Triage Agent',\n",
    "    instructions='You are a triage agent who decides which agent to handoff the query to',\n",
    "    handoffs = [ml_tutor_agent, spm_tutor_agent]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99287a9f",
   "metadata": {},
   "outputs": [],
   "source": [
    "async def main():\n",
    "    result = await Runner.run(triage_agent, 'What is a support vector?')\n",
    "    print(result.final_output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4848f5fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "if __name__ == '__main__':\n",
    "    await main()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
